/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bd.mdl;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Johnny
 */
@Entity
@Table(catalog = "ratings", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Movies.findAll", query = "SELECT m FROM Movies m"),
    @NamedQuery(name = "Movies.findByTitulo", query = "SELECT m FROM Movies m WHERE m.titulo = :titulo"),
    @NamedQuery(name = "Movies.findByGeneros", query = "SELECT m FROM Movies m WHERE m.generos = :generos"),
    @NamedQuery(name = "Movies.findByIdMovie", query = "SELECT m FROM Movies m WHERE m.idMovie = :idMovie")})
public class Movies implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(length = 100)
    private String titulo;
    @Column(length = 100)
    private String generos;
    @Id
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer idMovie;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "movies")
    private List<Rating> ratingList;

    public Movies() {
    }

    public Movies(Integer idMovie) {
        this.idMovie = idMovie;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public String getGeneros() {
        return generos;
    }

    public void setGeneros(String generos) {
        this.generos = generos;
    }

    public Integer getIdMovie() {
        return idMovie;
    }

    public void setIdMovie(Integer idMovie) {
        this.idMovie = idMovie;
    }

    @XmlTransient
    public List<Rating> getRatingList() {
        return ratingList;
    }

    public void setRatingList(List<Rating> ratingList) {
        this.ratingList = ratingList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMovie != null ? idMovie.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Movies)) {
            return false;
        }
        Movies other = (Movies) object;
        if ((this.idMovie == null && other.idMovie != null) || (this.idMovie != null && !this.idMovie.equals(other.idMovie))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bd.mdl.Movies[ idMovie=" + idMovie + " ]";
    }
    
}
